﻿using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Text;

namespace CSharpLearn.CLI {

  internal class Program {

    private static Task<int> Main(String[] args) {

      //var nameOption = new Option<string>("--name", "client name");
      var clientCommand = new Command("client", "my test client");
      clientCommand.AddAlias("c");
      clientCommand.AddOption(new Option<string?>("--name", "client name"));
      clientCommand.Handler = CommandHandler.Create(
          (string? name) => {
            if(name == null || name == ""){
              name = "client";
            }
            Console.WriteLine($"Hello I'm { name }!");
          });

      var rootCommand = new RootCommand("root command") {
        clientCommand
      };

      Console.OutputEncoding = Encoding.UTF8;
      return rootCommand.InvokeAsync(args);
    }

  }

}
